
use "${pathdata_baseline}/BaselineExperiment.dta", clear


* ### Belief Movement: Main Figure ###	
		
preserve		
		
	* Step 1: Clone the dataset
gen _clone = 1

* Step 2: Replace the values
* For the cloned dataset
replace effect = abs_belief * 100 if _clone == 1
replace effect_recall = abs_belief * 100 if _clone == 1
replace condition_ = "bayesian_movement_story" if _clone == 1 & inlist(condition_, "storyshort_neg", "storyshort_pos")
replace condition_ = "bayesian_movement_statistic" if _clone == 1 & inlist(condition_, "statistic_neg", "statistic_pos")

duplicates drop


* Step 3: Append the cloned dataset to the original one
append using "${pathdata_baseline}/BaselineExperiment.dta", gen(_source)


	gen temp_group = 0 if inlist(condition_, "storyshort_neg", "storyshort_pos")
	replace temp_group = 1 if inlist(condition_, "statistic_neg", "statistic_pos")
	replace temp_group = 2 if inlist(condition_, "bayesian_movement_story")
	replace temp_group = 3 if inlist(condition_, "bayesian_movement_statistic")
	keep if story_type=="consistent"
	bysort prolific_pid : drop if _N==1

drop if condition_ == "noinfo"



collapse (mean) effect effect_recall (sem) imm_sem = effect del_sem = effect_recall, by(temp_group)	 

list effect effect_recall
tab effect effect_recall
tabulate effect effect_recall
tabulate temp_group, summarize(effect)
tabulate temp_group, summarize(effect_recall)
tabulate temp_group, summarize(imm_sem)
tabulate temp_group, summarize(del_sem)



summarize effect
summarize effect_recall

	rename imm_sem sem0
	rename del_sem sem1
	rename effect dev0
	rename effect_recall dev1
	reshape long sem dev, i(temp_group) j(delay)
	gen upper=dev+sem
	gen lower=dev-sem
	
	
	* Move bayesian benchmark "to the outside"
	replace delay = delay - 0.05 if inlist(temp_group, 2,3) & delay == 0
	replace delay = delay + 0.05 if inlist(temp_group, 2,3) & delay == 1


	tw (scatter dev delay if temp_group == 0, connect(l) lcolor(black*0.5) lpattern(solid)  msize(large) ms(d) mcolor(black*0.5)) ///
		(scatter dev delay if temp_group == 1, connect(l) lcolor(black*1.5) lpattern(shortdash)   msize(large) ms(o) mcolor(black*1.5)) ///
			(scatter dev delay if temp_group == 2, connect(l) msize(0.00001) ms(d) lpattern(dash_dot) lcolor(black*0.5) mcolor(black*0.5)) ///
			(scatter dev delay if temp_group == 3, connect(l) msize(0.00001) ms(o) lpattern(longdash) color(black*1.5) mcolor(black*1.5)) ///
		(rcap upper lower delay if temp_group == 0, lw(medthick) lcolor(black*0.5))	///
		(rcap upper lower delay if temp_group == 1, lw(medthick) lcolor(black*1.5)),	///
	ytitle("Mean belief impact {c 177} SEM" "(percentage points)") ///
		xtitle(" ") xsc(r(-0.5 1.5) lcolor(none)) ysc(r(0 20) lcolor(none)) ///
		yline(0, lcolor(gs10) lwidth(thin)) ///
		graphregion(color(white)) title("Belief impact in {it:Immediate} and {it:Delay}",  margin(b=3) color(black)) ///
		ylabel(0 5 10 15 20, tlc(none) angle(0) glcolor(gs15) glwidth(thin)) ///
		legend(order(1 2 3 4) label(1 "Story") label(2 "Statistic") label(3 "Bayesian Benchmark: Story") label(4 "Bayesian Benchmark: Statistic") r(1)) ///
		xlabel(0 "Immediate" 1 "1-day delay") ysize(5) xsize(10)
		
		
	graph export "${pathout_baseline}/figures/figure1a.pdf", replace
	

restore



* ########## Combined Recall - Main Figure ##########

use "${pathdata_baseline}/BaselineExperimentRecall.dta", clear


preserve
	* Combined Recall, i.e. remember valence AND correct recall (Y) story or statistic (X)
	keep if inlist(condition_,"storyshort_neg", "storyshort_pos", "statistic_neg", "statistic_pos")  & story_type=="consistent"

	collapse (mean) recallcombined (seb) seb = recallcombined, by(statisticcondition)
	
	
	tabulate statisticcondition, summarize(recallcombined)
	tabulate statisticcondition, summarize(seb)

	gen h = recallcombined + seb
	gen l = recallcombined - seb

	tw (scatter recallcombined statisticcondition if statisticcondition == 0, mcolor(black*0.5) msize(large) ms(d))  ///
	(rcap h l statisticcondition if statisticcondition == 0, lw(medthick) lcolor(black*0.5)) ///
	(scatter recallcombined statisticcondition if statisticcondition == 1, mcolor(black*1.5) msize(large) ms(o)) ///
	(rcap h l statisticcondition if statisticcondition == 1, lw(medthick) lcolor(black*1.5)), ///
	graphregion(color(white)) ysc(r(0 0.8)) ylab(0(0.2)0.8, angle(horizontal) tlc(none)  glcolor(gs15) glwidth(thin))  ysc(lcolor(none))  xsc(r(-0.5 1.5) lcolor(none)) title("Correct recall of information type and valence",  margin(b=3) color(black)) ysize(5) xsize(10) ///
	yline(0, lcolor(gs10) lwidth(thin)) ///
	 xlab(0 "Story" 1 "Statistic" ,valuelabel) xtitle("Condition") ytitle(" " "Mean Rate  {c 177} SEM") leg(off)
	 
	graph export "${pathout_baseline}/figures/figure1b.pdf", replace







